Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body onhashchange="myFunction()"> <p>Click the button to change the anchor part of the current URL to #part5</p> <button onclick="changePart()">Try it</button> <p id="demo"></p> <script> // Using the location.hash property to change the anchor part function changePart() { location.hash = "part5"; var x = "The anchor part is now: " + location.hash; document.getElementById("demo").innerHTML = x; } // Alert some text if there has been changes to the anchor part function myFunction() { alert("The anchor part has changed!"); } </script> </body> <!-- Mirrored from www.w3schools.com/tags/tryit.asp?filename=tryhtml5_ev_onhashchange by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:09:05 GMT --> </html>
Result:
Try it Yourself - © w3schools.com